﻿using Orleans;
using System.Threading.Tasks;

namespace Puppy.CommonService
{
    /// <summary>
    /// 分布式锁服务
    /// </summary>
    public interface ILockActor : IGrainWithStringKey
    {
        /// <summary>
        /// 加锁
        /// </summary>
        /// <param name="millisecondsDelay">延迟等待毫秒数，等待超过指定时间后加锁失败，默认为0</param>
        /// <param name="maxSecondsHold">最大拥有锁时间（秒），默认为 30 秒</param>
        /// <returns></returns>
        Task<bool> LockAsync(int millisecondsDelay = 0, int maxSecondsHold = 30);

        /// <summary>
        /// 解锁
        /// </summary>
        /// <returns></returns>
        Task UnlockAsync();
    }
}
